package com.micromall.controller;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.micromall.common.utils.Dict;
import com.micromall.model.BusiProduct;
import com.micromall.service.IBusiProductService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * Created by DanteFung on 2017/7/26.
 */
@Controller
@RequestMapping("/home")
public class HomeController {

    private static final Logger logger = LoggerFactory.getLogger(HomeController.class);

    private static final String HOME_PAGE = "home/homeIndex";

    @Autowired
    private IBusiProductService busiProductService;


    /**
     * 跳转到首页
     * @return
     */
    @RequestMapping("/index")
    public String index(HttpServletRequest request){
        EntityWrapper<BusiProduct> ew = new EntityWrapper<BusiProduct>();
        BusiProduct busiProduct = new BusiProduct();
        busiProduct.setDataStatus(Dict.YesOrNo.Yes.getCode());
        busiProduct.setPublishStatus(Dict.YesOrNo.Yes.getCode());
        ew.setEntity(busiProduct);

        List<BusiProduct> busiProductList =  busiProductService.selectList(ew);
        request.setAttribute("busiProductList",busiProductList);
        return HOME_PAGE;
    }


    /**
     * 跳转到订单页
     * @return
     */
    @RequestMapping("/do_order_Page")
    public String do_order_Page(HttpServletRequest request){

        return "/order/order";
    }

}
